const storage = window.localStorage

/* eslint-disable */
const local = {
    save : function(key, value) {
    if (typeof value === 'object') {
        value = JSON.stringify(value)
    }
    storage.setItem(key, value)
    },

    saveMulti: function(datas) {
    datas.forEach(data => save(data.key, data.value))
    },

    read: function(key) {
    return storage.getItem(key)
    },

    readMulti:function(keys) {
    return keys.map(key => read(key))
    },

    clear:function(key, clearAll = false) {
    if (clearAll) {
        storage.clear()
    } else {
        storage.removeItem(key)
    }
    },

    clearMulti:function(keys) {
    keys.forEach(key => clear(key))
    }
}
export default local